﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace Minigolf.Gamestates
{
    public enum RenderStage { PreWorld, PostWorld, PreLighting, PostLighting, PreGui, PostGui }

    public abstract class BaseState
    {
        protected object persData;

        public BaseState()
        {

        }

        public virtual void Init(Game source) { }
        public virtual void Update(GameTime gameTime) { }
        public virtual void Render(RenderStage render, SpriteBatch batch) { }
        public virtual void Shutdown() { }
    }

    public class StateManager
    {
        public BaseState ActiveState { get; private set; }
        public string StateString = "";
        private Game source;

        public StateManager(Game source)
        {
            ActiveState = null;
            this.source = source;
        }

        public void SetNull()
        {
            if (ActiveState != null) ActiveState.Shutdown();
            ActiveState = null;
        }

        public void Set<T>() where T : BaseState
        {
            SetNull();
            ActiveState = Activator.CreateInstance<T>();
            ActiveState.Init(source);
            StateString = ActiveState.ToString();
        }

        public string GetState()
        {
            return StateString;
        }
    }


}
